//使用mongoose将服务器和数据库连接起来
const mongoose = require("mongoose");
//暴露
module.exports = new Promise((resolve,reject)=>{
    //初始化状态
    mongoose.connect("mongodb://localhost:27017/student_2203",{useNewUrlParser:true,useUnifiedTopology:true,useCreateIndex:true});
    //监听是否连接
    mongoose.connection.once("open",err=>{
        if(!err){
            console.log('数据库连接成功！');
            resolve();
        }else{
            console.log(err);
            reject(err);
        }
    })
})